home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / CHAP01.TXT < prev    next >
Text File  |  1989-12-30  |  8KB  |  191 lines

  1.                         Chapter 1 - Getting Started
  2.  
  3.  
  4.                           WHAT IS AN IDENTIFIER?
  5.  
  6.              Before you can do anything in any language, you must at 
  7.         least  know  how you name an identifier.   An identifier  is 
  8.         used for any variable,  function,  data definition, etc.  In 
  9.         the programming language C,  an identifier is a  combination 
  10.         of alphanumeric characters,  the first being a letter of the 
  11.         alphabet or an underline, and the remaining being any letter 
  12.         of the alphabet,  any numeric digit,  or the underline.  Two 
  13.         rules must be kept in mind when naming identifiers.
  14.  
  15.         1.   The  case  of  alphabetic  characters  is  significant.  
  16.              Using  "INDEX" for a variable is not the same as  using 
  17.              "index"  and  neither  of them is  the  same  as  using 
  18.              "InDeX"  for a variable.   All three refer to different 
  19.              variables.
  20.  
  21.         2.   As C is defined, up to eight significant characters can 
  22.              be  used and will be considered significant.   If  more      
  23.              than  eight  are  used,  they may  be  ignored  by  the      
  24.              compiler.   This  may  or  may  not  be  true  of  your 
  25.              compiler.  You  should  check your reference manual  to 
  26.              find  out how many characters are significant for  your 
  27.              compiler.
  28.  
  29.              It  should be pointed out that some C  compilers  allow 
  30.         use of a dollar sign in an identifier name,  but since it is 
  31.         not  universal,  it  will  not  be  used  anywhere  in  this 
  32.         tutorial.    Check  your  documentation  to  see  if  it  is 
  33.         permissible for your particular compiler.
  34.  
  35.                          WHAT ABOUT THE UNDERLINE?
  36.  
  37.              Even  though  the  underline can be used as part  of  a 
  38.         variable  name,   it  seems  to  be  used  very  little   by 
  39.         experienced   C  programmers.    It  adds  greatly  to   the 
  40.         readability  of  a  program  to use  descriptive  names  for 
  41.         variables  and  it  would be to your  advantage  to  do  so.  
  42.         Pascal  programmers tend to use long descriptive names,  but 
  43.         most C programmers tend to use short cryptic names.  Most of 
  44.         the  example programs in this tutorial use very short  names 
  45.         for that reason.
  46.  
  47.              Any computer program has two entities to consider,  the 
  48.         data,  and  the program.   They are highly dependent on  one 
  49.         another  and  careful planning of both will lead to  a  well 
  50.         planned and well written program.   Unfortunately, it is not 
  51.         possible  to study either completely without a good  working 
  52.         knowledge of the other.  For this reason, this tutorial will 
  53.         jump  back  and forth between teaching  methods  of  program 
  54.         writing  and  methods of data  definition.    Simply  follow 
  55.  
  56.  
  57.                                  Page 4
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                         Chapter 1 - Getting Started
  68.  
  69.  
  70.         along and you will have a good understanding of both.   Keep 
  71.         in  mind that,  even though it seems expedient to  sometimes 
  72.         jump right into the program coding,  time spent planning the 
  73.         data  structures  will be well spent and the  final  program 
  74.         will reflect the original planning.
  75.  
  76.                         HOW THIS TUTORIAL IS WRITTEN
  77.  
  78.              As  you go through the example programs,  you will find 
  79.         that  every  program  is complete.   There  are  no  program 
  80.         fragments that could be confusing.   This allows you to  see 
  81.         every  requirement that is needed to use any of the features 
  82.         of C as they are presented.  Some tutorials I have seen give 
  83.         very few, and very complex examples.  They really serve more 
  84.         to  confuse  the student.   This tutorial  is  the  complete 
  85.         opposite  because  it  strives to cover each new  aspect  of 
  86.         programming  in  as  simple a  context  as  possible.   This 
  87.         method,  however,  leads  to a lack of knowledge in how  the 
  88.         various  parts  are combined.   For that  reason,  the  last 
  89.         chapter is devoted entirely to using the features taught  in 
  90.         the  earlier  chapters.  It will illustrate how to  put  the 
  91.         various features together to create a usable program.   They 
  92.         are given for your study,  and are not completely explained.  
  93.         Enough  details of their operation are given to allow you to 
  94.         understand how they work after you have completed all of the 
  95.         previous lessons. 
  96.  
  97.                      A DISCUSSION OF SOME OF THE FILES
  98.  
  99.                                    CCL.BAT
  100.  
  101.              This  file,  which  does not exist on the  distribution 
  102.         disk,  is the batch file that calls in an editor,  then  the 
  103.         compiler (Pass 1 and Pass 2, if it exists), and finally runs 
  104.         the resulting compiled program.   There are several examples 
  105.         of  batch  files  which can be used with  various  compilers 
  106.         given  in  the  "COMPILER.DOC"  file  on  the   distribution 
  107.         diskette.   It  is up to you to type in a batch file for use 
  108.         with your particular compiler,  considering also the  method 
  109.         required to call in your editor.  To use it, simply type the 
  110.         batchfile  name with the desired filename.   After typing in 
  111.         your particular CCL.BAT file,  try it by typing CCL FIRSTEX.  
  112.         You  will  get the source file displayed on the  monitor  by 
  113.         your editor.   If you don't have one of the compilers listed 
  114.         in  the  "COMPILER.DOC" file,  you will have to  modify  the 
  115.         batch file for your particular compiler.
  116.          
  117.              The  pass or passes of the compiler will  be  executed, 
  118.         followed by the linking process.   The final program will be 
  119.         loaded and run, then the files generated by the process will 
  120.         be erased to prevent filling the disk up. 
  121.  
  122.  
  123.                                  Page 5
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                         Chapter 1 - Getting Started
  134.  
  135.  
  136.  
  137.              If you have a hard disk available, it will be up to you 
  138.         to  modify  the  batch file to perform the  above  described 
  139.         operations.
  140.  
  141.              Even though you will have a lot of files to compile and 
  142.         run, you will find that a batch file similar to this will do 
  143.         most of the work for you and you will proceed very quickly.
  144.  
  145.              In order to do the programming exercises, you will need 
  146.         to  go  through the same steps as when running  the  example 
  147.         programs.   This  is simple to do by simply typing your  own 
  148.         filename   with  the  CCL  program  call.    It  is   highly 
  149.         recommended  that you do the programming exercises  to  gain 
  150.         the programming experience.
  151.  
  152.                                   LIST.EXE
  153.  
  154.              This  file will list the source files for you with line 
  155.         numbers  and  filename.   To  use  it,  simply  type  "LIST" 
  156.         followed by the appropriate filename.   Type LIST  FIRSTEX.C 
  157.         now  for  an example.   The C source code is given later  in 
  158.         Chapter 14 along with a brief description of its operation.
  159.  
  160.                                 PRINTALL.BAT
  161.  
  162.              This is a batch file that will call the above  LIST.EXE 
  163.         file  once for each of the example C programs,  printing all 
  164.         of  the  files out.   If you want a hardcopy of all  of  the 
  165.         files,  enter PRINTALL and watch as your printer fills about 
  166.         150 sheets of paper with C programs. 
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.                                  Page 6
  190.  
  191.